//
//  IManager+LoginRequest.m
//  RocketProject
//
//  Created by chen jiedan on 13-7-1.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+LoginRequest.h"
#import "FrameworkRelativeDefines.h"
#import "RequestUtlity.h"
#import "RCLoginDataModel.h"


@implementation IManager (LoginRequest)

-(int64_t)requestLogin:(NSString *)userName withPassword:(NSString *)password withDelegate:(id<IManagerDelegate>)delegate
{
    if (nil == userName || password == nil) {
        return kInvalidRequestId;
    }
    // 异步获取数据
  
    NSString *url = [RequestUtlity getFormattedUrl:kRCLoginUrlPrefix];
    
    NSDictionary *postDic = @{@"username": userName,@"password":password};
//    NSDictionary *userInfo =@{@"PostDataValue": postDic};
//    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"LoginJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];

    
  return  [[IDataProvider sharedInstance] asyncPostData:url postValues:postDic postDataList:nil userInfo:nil withDataParseClass:[RCLoginDataModel class] withDataDelegate:delegate];
    
}


-(int64_t)postModify:(NSString *)oldPass withPassword:(NSString *)newPass andBduss:(NSString*)bduss withDelegate:(id<IManagerDelegate>)delegate
{
    if (nil == oldPass || newPass == nil  || bduss == nil) {
        return kInvalidRequestId;
    }
    // 异步获取数据
    
    NSString *url = [RequestUtlity getFormattedUrl:kRCModifyPassUrlPrefix];
    
    NSDictionary *postDic = @{@"oldpassword": oldPass,@"newpassword":newPass,@"bduss":bduss};
    
    return  [[IDataProvider sharedInstance] asyncPostData:url postValues:postDic postDataList:nil userInfo:nil withDataParseClass:[RCLoginDataModel class] withDataDelegate:delegate];
}


//商户宝登录页面
-(int64_t)requestServerLogin:(NSString *)userName withPassword:(NSString *)password withDelegate:(id<IManagerDelegate>)delegate
{
    if (nil == userName || password == nil) {
        return kInvalidRequestId;
    }
    NSString *url = [RequestUtlity getFormattedUrl:kRCServerLoginUrlPrefix];
    
    NSDictionary *postDic = @{@"username": userName,@"password":password};
    //    NSDictionary *userInfo =@{@"PostDataValue": postDic};
//    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"ServerLoginJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    
    
    return  [[IDataProvider sharedInstance] asyncPostData:url postValues:postDic postDataList:nil userInfo:nil withDataParseClass:[RCServerLoginDataModel class] withDataDelegate:delegate];
    
}

@end
